<?php
namespace Admin\Controller;

use Common\Controller\AdminBaseController;

/**
 * 后台首页控制器
 */
class IndexController extends AdminBaseController
{
    /**
     * 首页
     */
    public function index()
    {

        $this->display();
    }
    /**
     * elements
     */
    public function elements()
    {

        $this->display();
    }

    /**
     * welcome
     */
    public function welcome()
    {
        //今日注册用户
        $time                 = strtotime(date('Y-m-d', time()));
        $data['member_today'] = M('member')->where('add_time>=' . $time)->count();
        if ($data['member_today'] == '') {
            $data['member_today'] = 0;
        }
        //今日充值
        $data['cash'] = M('cash_m')->where('type=1 and add_time>=' . $time)->sum('money');
        if ($data['cash'] == '') {
            $data['cash'] = '0.00';
        }
        //今日提现
        $data['tx'] = M('cash_m')->where('type=0 and add_time>=' . $time)->sum('money');
        if ($data['tx'] == '') {
            $data['tx'] = '0.00';
        }
        //今日投注
        $data['touzhu'] = M('lottery_order')->where('add_time>=' . $time)->sum('money');
        if ($data['touzhu'] == '') {
            $data['touzhu'] = '0.00';
        }
        //今日盈亏
        $lost        = M('lottery_order')->where('add_time>=' . $time)->sum('lost_money');
        $win         = M('lottery_order')->where('add_time>=' . $time)->sum('win_money');
        $data['win'] = abs($lost) - abs($win);
        if ($data['win'] == '') {
            $data['win'] = '0.00';
        }
        $this->assign('data', $data);
        $this->display();
    }
    public function get_cash()
    {
        $info = M('cash_m')->where('type=1 and status=0')->order('id desc')->find();
        if (empty($info)) {
            $data['status'] = 0;
        } else {
            $data['status'] = 1;
        }
        $data['text'] = "会员id：" . $info['m_id'] . ",充值：" . $info['money'] . "，请处理";
        // die(json_encode($data));
        $this->ajaxReturn($data);
    }

}
